package com.lws.framework.module.usercenter.controller;

import javax.annotation.security.RolesAllowed;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lws.framework.module.usercenter.bean.User;
import com.lws.framework.module.usercenter.service.UserService;

@Controller
@RequestMapping("/user.do")
public class UserController {

    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping(params = "method=getCurrentUser")
    public User getCurrentUser() {
        User user = userService.getCurrentUser();
        return user;
    }

    @RolesAllowed("admin")
    @RequestMapping(params = "method=updateUser")
    public void updateUser() {
        User user = userService.getCurrentUser();
        user.setUsername("root");
        userService.update(user);
    }
}
